<?php
//Función Refrescar Pagina
$self = $_SERVER['PHP_SELF']; //Obtenemos La Página En La Que Nos Encontramos 
header("refresh:300;  url=$self");//Refrescamos Cada 300 Segundos (5 Minutos)

session_start();
if (!isset($_SESSION['usuario'])) {
    header('location:../html/login.html');
}

echo '
                <center></title>
                    <table>
                        <tr>
                            <td>';
include_once 'menu.php';
echo"</td>
                        </tr>
                    </table>";

/*include_once '../../controlador/php/conexion/Conexion.php';    
$con  = new Conexion();

mssql_connect("192.168.10.3\DINAMICA", "sa", "admin4");
mssql_select_db("DGempres10");*/
$listado = " SELECT GENPACIEN.PACNUMDOC AS DOCUMENTO, RTRIM(GENPACIEN.PACPRINOM)+' '+RTRIM(GENPACIEN.PACSEGNOM) +' '+  RTRIM(GENPACIEN.PACPRIAPE)+' '+ RTRIM(GENPACIEN.PACSEGAPE) AS NOMBRES, 
                    SUBSTRING(CONVERT (VARCHAR(10),GENPACIEN.GPAFECNAC,103),1,10) AS FECHANAC ,  CAST(DATEDIFF(DD, GENPACIEN.GPAFECNAC, GETDATE()) / 365.25 AS INT) AS EDAD,
                    ADNINGRESO.AINCONSEC AS INGRESO, SUBSTRING(CONVERT (VARCHAR(10),ADNINGRESO.AINFECING,103),1,10)+' '+CONVERT(VARCHAR(5), ADNINGRESO.AINFECING, 114) AS FECHAINGRESO,
                    RTRIM(GENDETCON.GDECODIGO)+' - '+RTRIM(GDENOMBRE) AS ASEGURADORA
                    FROM  DGempres10..GENPACIEN INNER JOIN DGempres10..ADNINGRESO ON GENPACIEN.OID=ADNINGRESO.GENPACIEN
                    INNER JOIN DGempres10..GENDETCON ON ADNINGRESO.GENDETCON=GENDETCON.OID
                    WHERE ADNINGRESO.AINESTADO NOT IN (2) AND  ADNINGRESO.AINCAUING=9 and ADNINGRESO.AINFECING between '01/01/2014 00:00' and GETDATE()
                    ORDER BY SUBSTRING(CONVERT (VARCHAR(10),ADNINGRESO.AINFECING,103),1,10)+' '+CONVERT(VARCHAR(5), ADNINGRESO.AINFECING, 114) DESC
";
$res = mssql_query($listado);
?>

<!DOCTYPE HTML>
<html>
    <head>
        
        <meta http-equiv="Content-Type" content="text/html; charset= UTF-8 " />

        <script src="../../Quirofano/vista/tabla/media/js/jquery.js" type="text/javascript"></script>
        <script src="../../Quirofano/vista/tabla/media/js/jquery.dataTables.js" type="text/javascript"></script>

        <style type="text/css">
            @import "../../Quirofano/vista/tabla/media/css/demo_table_jui.css";
            @import "../../Quirofano/vista/tabla/media/themes/smoothness/jquery-ui-1.8.4.custom.css";

            #gineco{
                font-size: 75%;
            }
            #filas{
                font-size: 60%;
            }
            #apDiv1{ 
                width: 100%;
                background-color: white;
                border-radius: 20px;
                border:1px solid #d3d3d3;
                background:#fefefe;width:auto;
                height: auto;
                margin:1% auto 0;
                -moz-border-radius:8px;
                /* FF1+ */-webkit-border-radius:8px;
                /* Saf3-4 */border-radius:8px;
                -moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
                -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
            }
            #gineco2{
                width:93%;
                height: auto;
            }
            #titulo {
                font-size: 16px;
                color: #323133;
                font-family: Helvetica Neue, Arial, Helvetica, sans-serif;
                letter-spacing: -1px;
                text-decoration: none; 
                text-shadow: 1px 1px #fff, 0 0 #0e0e0e, 2px 3px 1px #e3e3e3; 
                text-transform: none; 
                word-spacing: -2px;
            }

            #tc{
                margin-top: -1%;
            }

            label,input,button,select,textarea{font-size:14px;font-weight:normal;line-height:20px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:28px;padding:4px 6px;margin-bottom:10px;font-size:14px;line-height:20px;color:#555;vertical-align:middle;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}input,textarea,.uneditable-input{width:170px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px}select{width:170px;background-color:#fff;border:1px solid #ccc}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.uneditable-input,.uneditable-textarea{color:#999;cursor:not-allowed;background-color:#fcfcfc;border-color:#ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}.uneditable-input{overflow:hidden;white-space:nowrap}.uneditable-textarea{width:auto;height:auto}input:-moz-placeholder,textarea:-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}.radio,.checkbox{min-height:20px;padding-left:20px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-20px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:926px}input.span11,textarea.span11,.uneditable-input.span11{width:846px}input.span10,textarea.span10,.uneditable-input.span10{width:766px}input.span9,textarea.span9,.uneditable-input.span9{width:686px}input.span8,textarea.span8,.uneditable-input.span8{width:606px}input.span7,textarea.span7,.uneditable-input.span7{width:526px}input.span6,textarea.span6,.uneditable-input.span6{width:446px}input.span5,textarea.span5,.uneditable-input.span5{width:366px}input.span4,textarea.span4,.uneditable-input.span4{width:286px}input.span3,textarea.span3,.uneditable-input.span3{width:206px}input.span2,textarea.span2,.uneditable-input.span2{width:126px}input.span1,textarea.span1,.uneditable-input.span1{width:46px}.controls-row{*zoom:1}.controls-row:before,.controls-row:after{display:table;line-height:0;content:""}.controls-row:after{clear:both}.controls-row [class*="span"],.row-fluid .controls-row [class*="span"]{float:left}.controls-row .checkbox[class*="span"],.controls-row .radio[class*="span"]{padding-top:5px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning .control-label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853}.control-group.warning input,.control-group.warning select,.control-group.warning textarea{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}
        </style>

        <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                $('#datatables').dataTable({
                    "sPaginationType": "full_numbers",
                    "aaSorting": [[2, "desc"]],
                    "bJQueryUI": true
                });
            });

        </script>   
    </head>
    <body>
    <center>
        <table id="titulo">
            <tr>
                <td>
                    GINECO - OBSTETRICIA
                </td>
            </tr>
        </table>
        <table align="center" id="gineco2">
            <tr>
                <td>
                    <div id="apDiv1"> 
                        <table id="tc" width="100%" align="center" class="breadcrumb">
                            <tr>
                                <th>&nbsp;</th>
                                <th>&nbsp;</th>
                                <th height="125" scope="col"><br>
                            <table width="103%" height="50" class="display" id="datatables">
                                <thead>
                                    <tr id="gineco">
                                        <th>Documento</th>
                                        <th>Nombres</th>
                                        <th>Fecha de Nacimiento</th>
                                        <th>Edad</th>
                                        <th>Ingreso</th>
                                        <th>Fecha de Ingreso</th>
                                        <th>Aseguradora</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    while ($res2 = mssql_fetch_array($res)) {
                                        echo '<tr id="filas">
                                                <td align="center">' . $res2["DOCUMENTO"] . '</td>
                                                <td align="center">' . $res2["NOMBRES"] . '</td>
                                                <td align="center">' . $res2["FECHANAC"] . '</td>
                                                <td align="center">' . $res2["EDAD"] . '</td>
                                                <td align="center">' . $res2["INGRESO"] . '</td>
                                                <td align="center">' . $res2["FECHAINGRESO"] . '</td>
                                                <td align="center">' . $res2["ASEGURADORA"] . '</td>
                                              </tr>';
                                    }
                                    mssql_close();
                                    ?>
                                </tbody>
                            </table>
                            </th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            </tr>
                        </table>
                        </br>
                    </div>
                </td>
            </tr>
        </table>
        </br>
    </center>
</body>
</html>